package com.example.campuslink.commen.db

import androidx.room.TypeConverter
import com.example.campuslink.commen.db.comment.CommentTable
import com.example.campuslink.commen.db.invitation.InvitationTable
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken

class ListListCommentTableConverter {
    private val gson = Gson()
    private val listType = object : TypeToken<MutableList<MutableList<CommentTable>>>() {}.type

    @TypeConverter
    fun fromString(value: String): MutableList<MutableList<CommentTable>>? {
        return if (value.isBlank()) null else gson.fromJson(value, listType)
    }

    @TypeConverter
    fun fromList(list: MutableList<MutableList<CommentTable>>?): String {
        return gson.toJson(list ?: emptyList<CommentTable>())
    }
}